package com.freshmarket.fresh.vo;

import lombok.Data;
import sun.plugin2.message.Message;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @Author tedu-sysh-lrf
 */
@Data
public class JsonResult<T> extends HashMap<String, Object> implements Serializable {

    private Integer code;
    private String message;
    private Object data;

    public JsonResult() {
    }

    public JsonResult(Integer code, String message) {
        super.put("code",code);
        super.put("message",message);
    }

    public JsonResult(Integer code, String message, Object data) {
        super.put("code",code);
        super.put("message",message);
        super.put("data", data);
    }

    public static JsonResult fail(){
        return new JsonResult(20001,"服务器运行失败",null);
    }

    public static JsonResult fail(String message){
        return new JsonResult(20001,message,null);
    }

    public static JsonResult success(){
        return new JsonResult(20000,"服务器运行成功",null);
    }

    public static JsonResult success(Object data){
        return new JsonResult(20000,"服务器运行成功",data);
    }

    public static JsonResult success(String message,Object data){
        return new JsonResult(20000,message,null);
    }
}
